﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using CompanyBussiness;

namespace Website.customer.ws
{
    /// <summary>
    /// Summary description for wsProductServices
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class wsProductServices : System.Web.Services.WebService
    {
        private CompanyDataContext companydata = new CompanyDataContext();

        [WebMethod]
        public List<string> GetChildProductByParent(int parentTypeProductID)
        {

            return companydata.TypeProducts.Where(p => p.ParentTypeProductID == parentTypeProductID).Select(
                         p => p.TypeProductID.ToString() + "|" + p.TypeProductName).ToList();
            
        }

        [WebMethod]
        public List<string> GetProductByChildTypeProduct(int typeProductID)
        {
            return
                companydata.Products.Where(d => d.TypeProductID == typeProductID).Select(
                    d => d.ProductID.ToString() + "|" + d.ProductName).ToList();
        }
    }
}
